import request from '../../../utils/request'

// 查询用户列表
export function listUser (query) {
  return request({
    url: '/system/user/userList',
    method: 'get',
    params: query
  })
}

// 查询用户详细
export function getUser () {
  return request({
    url: '/system/user/getUser',
    method: 'get'
  })
}
// 新增用户
export function addUser (data) {
  return request({
    url: '/system/user/addUser',
    method: 'post',
    data: data
  })
}

// 修改用户
export function updateUser (data) {
  return request({
    url: '/system/user/updateUser',
    method: 'post',
    data: data
  })
}
export function getUserInfoById (userId) {
  return request({
    url: '/system/user/getUserInfoById?id=' + userId,
    method: 'get'
  })
}

// 导出用户
export function exportUser (query) {
  return request({
    url: '/system/user/export',
    method: 'get',
    params: query
  })
}
// 删除用户
export function delUser (userId) {
  let userIds = []
  if (!Array.isArray(userId)) {
    userIds.push(userId)
  } else {
    userIds = userId
  }
  return request({
    url: '/system/user/delUser',
    method: 'delete',
    data: userIds
  })
}
// 用户密码重置
export function resetUserPwd (userId, password) {
  const data = {
    userId,
    password
  }
  return request({
    url: '/system/user/resetUserPwd',
    method: 'post',
    data: data
  })
}
